package com.applcn.user.constant;

import com.baomidou.mybatisplus.core.enums.IEnum;

/**
 * com.applcn.user.constant
 * Description:
 *
 * @author: 大妖怪
 * @date: 2020-01-18 00:38
 */
public enum GenderEnum implements IEnum<Integer> {
    UNKNOWN(0, "未知"),
    MALE(1, "男"),
    FEMALE(2, "女");

    private int code;
    private String desc;

    GenderEnum(int code, String desc) {
        this.code = code;
        this.desc = desc;
    }

    /**
     * 通过code获取性别
     * @param code
     * @return
     */
    public static GenderEnum getGenderEnum(int code){
        for (GenderEnum genderEnum:GenderEnum.values()) {
            if (genderEnum.getCode() == code) {
                return genderEnum;
            }
        }

        return null;
    }

    public int getCode() {
        return code;
    }

    public String getDesc() {
        return desc;
    }

    @Override
    public Integer getValue() {
        return this.getCode();
    }
}
